﻿
<%@ page language="java" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/jsp/taglib.jsp"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>DataConverge</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="css/style.css">
<script type="text/javascript">
      var xmlHttp;
      var url="";
      var delNode;
      function createXMLHttpRequest() {
			if (xmlHttp == null) {
	    		if (window.ActiveXObject) {
	    			xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
	    		}
	    		else if (window.XMLHttpRequest) {
	        		xmlHttp = new XMLHttpRequest();                
	    		}
    		}
	  }
		function uploadDoc(){
			var id=document.form0.subjectId.value;
			document.location.href="document.htm?subjectId="+id;
		}
		function manageFund(){
			var id=document.form0.subjectId.value;
			document.location.href="fund.htm?subjectId="+id;
		}
		
		function goback(){
      	var page=document.form0.page.value;
      	var subjectId=document.form0.subjectId.value;
      	if(page!="" && subjectId!=""){
      		//document.location.href='subject.htm?ec_p='+page;
      		document.location.href="subjectModify.htm?subjectId="+subjectId+"&page="+page;
      	}else{
      		document.location.href='subject.htm?ec_p='+page;;
      	}
       }
       
      function delFund(fundId,node){
       	if(!window.confirm("确定删除此经费？","确定","取消"))	
        return;
       	url="subject.htm?action=delFund&fundId="+fundId;
      	delNode=node.parentNode.parentNode;
      	createXMLHttpRequest();
		xmlHttp.open("GET", url, true);
    	xmlHttp.onreadystatechange = callback;
    	xmlHttp.send(null);
      }
      
      function callback(){
      	if(xmlHttp.readyState==4){
    			if(xmlHttp.status==200){
    				var xmlDoc = xmlHttp.responseXML;
					var nodes = xmlDoc.getElementsByTagName('fundDeleted');
					var deleted=nodes[0].firstChild.nodeValue;					
    				if(deleted==1){
    					delNode.parentNode.removeChild(delNode);
    				}else{
      					var errMsg=xmlDoc.getElementsByTagName('errMsg')[0].firstChild.nodeValue;
      					alert(errMsg);
      				}
    			}
    	}
      }
	</script>
</head>

<body>
<br>
<DIV align="center"><strong>已获经费信息</strong></DIV>
<TABLE border="1" width="70%" align="center">
	<TR>
		<TD>获取经费</TD>
		<TD>年份</TD>
		<c:if test="${subject.state!='1'}">
		<TD>删除</TD>
		</c:if>
	</TR>
	<c:forEach items="${fundList}" var="fund">
		<TR>
			<td><c:out value="${fund.receiveFund}" /></td>
			<td><c:out value="${fund.year}" /></td>
			<c:if test="${subject.state!='1'}">
			<td><a href="#" onclick="delFund(${fund.id},this);"><img
				src="images/delete.gif" /></a></td>
			</c:if>
		</TR>
	</c:forEach>
</TABLE>

<br>
<form name="form0" action="fund.htm" method="post"><input type="hidden"
	name="subjectId" value='${subject.id}'> <input type="hidden"
	name="page" value='${page}'>
<div align="center">
<h3>添加年度实收经费</h3>
</div>
<table border="1" width="70%" align="center" height="50%">
	<tr>
		<td>课题名称</td>
		<td><c:out value='${subject.subjectName}' /></td>
	</tr>
	<tr>
		<td>开始时间</td>
		<td><c:out value='${subject.startDate}' />&nbsp;</td>
	</tr>
	<tr>
		<td>结束时间</td>
		<td><c:out value='${subject.endDate}' />&nbsp;</td>
	</tr>
	<tr>
		<td>中标经费</td>
		<td><c:out value='${subject.permitFund}' />万元</td>
	</tr>
	<tr>
		<td>实收经费</td>
		<td><input type="text" name="receiveFund" value="0.0" size="5">万元</td>
	</tr>
	<tr>
		<td>年份</td>
		<td><select name="year">
			<c:forEach items="${years}" var="year" varStatus="loopStep">
				<option value="${year}"><c:out value="${year}" /></option>;
    		</c:forEach>
		</select></td>
	</tr>

</table>
<br>
<table align="center">
	<TR>
		<TD>
		<c:if test="${subject.state!='1'}">
		<input type="submit" value="提交">&nbsp;&nbsp;
		</c:if>
		 <input type="button"
			value="返回" onclick="history.back(-1)">
		</TD>
	</TR>
</table>
</form>
</body>
</html>
